import table from '@/components/dt/table/render.js'
import tool from '@/common/tool.js'
import Opt from '@/components/dt/info/Opt.js'
let _this = null

class Column extends Opt {
  constructor(vm) {
    super()
    _this = vm
    this.build()
  }

  build() {
    this.createAll()
    this.opts.push(...this.all)
  }

  createAll() {
    this.all = [{
      field: 'positionName',
      title: '岗位名称',
      minWidth: 110
    },
    {
      field: 'bonusFlag',
      title: '是否参与奖金结算',
      minWidth: 110,
      slots: {
        default: (params, h) => {
          return [h('div', params.row.bonusFlag == 1 ? '是' : '否')]
        }
      }
    },
    {
      field: 'updateTime',
      title: '最近更新日期',
      minWidth: 100,
      slots: {
        default: (params, h) => {
          return [h('div', tool.formatterDate(params.row.updateTime))]
        }
      }
    },
    {
      field: 'stateFlag',
      title: '岗位状态',
      minWidth: 80,
      slots: {
        default: (params, h) => {
          return [h('div', params.row.stateFlag == 1 ? '启用' : '禁用')]
        }
      }
    },
    {
      field: 'roleNames',
      title: '对应角色',
      minWidth: 180
    },
    {
      field: 'rankOrderNames',
      title: '对应职级',
      minWidth: 180,
    },
    {
      field: 'createName',
      title: '操作人',
      minWidth: 80
    }, {
      field: 'handles',
      title: '操作',
      width: 170,
      fixed: 'right',
      cell: (item) => {
        let btn = []
        btn.push({
          title: '编辑',
          event: 'onEdit',
          code: '0211020000',
        })
        if (item.stateFlag == 1) {
          btn.push({
            title: '禁用',
            event: 'onDisable',
            code: '0211030000',
          })
        } else {
          btn.push({
            title: '启用',
            event: 'onDisable',
            code: '0211030000',
          })
        }

        return {
          btn
        }
      }
    }]
  }

}

export default Column